<template>
  <div ref="test" class="chat-main"></div>
</template>

<script>
import * as echarts from 'echarts';
export default {
  props: {
    regionData: Object
  },
  watch: {
    'regionData.xAxis'() {
      this.drawEcharts();
    }
  },

  methods: {
    drawEcharts() {
      var myChart = echarts.init(this.$refs.test, 'dark');

      // 指定图表的配置项和数据
      var option = {
        backgroundColor: '#121626',
        color: ['#333FFF', '#23B899'],
        grid: {
          left: '3%',
          right: '30px',
          bottom: '20px',
          top: '20px',
          containLabel: true
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross'
          }
        },
        xAxis: {
          type: 'category',
          data: this.regionData.xAxis
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: this.regionData.series1,
            type: 'bar',
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            barWidth: 14
          }
        ]
      };

      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    }
  },
  mounted() {
    this.drawEcharts();
  }
};
</script>

<style></style>
